package android.team.app.ui.missatoll;

import android.content.Intent;
import android.os.Bundle;
import android.team.app.R;
import android.team.app.ui.BaseActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.Spinner;

public class VehicleInformationActivity extends BaseActivity implements OnClickListener{
	private Spinner spState, spVehicleClass;
	private String state, vehicle;
	private ImageButton btNext;
	@Override
	protected void onCreate(Bundle savedInstanceState) {	
		super.onCreate(savedInstanceState);
		setContentView(R.layout.vehicle_information_activity);
		loadUI();
		titleHeader.setText(getString(R.string.vehicle_information));
		loadSpecialUI();
		
	}
	private void loadSpecialUI() {
		spState=(Spinner)findViewById(R.id.spState);
		spState.setAdapter(new ArrayAdapter<String>(baseActivity,
				android.R.layout.simple_spinner_item, 
				getResources().getStringArray(R.array.states)));
		
		spState.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view,
					int pos, long id) {
				state=parent.getItemAtPosition(pos).toString();
				
			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				state="CA";
				
			}
		
		});
		
		
		spVehicleClass=(Spinner)findViewById(R.id.spVehicleClass);
		spVehicleClass.setAdapter(new ArrayAdapter<String>(baseActivity,
				android.R.layout.simple_spinner_item, 
				getResources().getStringArray(R.array.vehicleClass)));
		
		spVehicleClass.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view,
					int pos, long id) {
				vehicle=parent.getItemAtPosition(pos).toString();
				
			}

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				vehicle="Automobile or motorcycle or any 2 axled truck";
				
			}
		
		});
		
		btNext=(ImageButton)findViewById(R.id.btNext);
		btNext.setOnClickListener(this);
		
	}
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btNext:
			startActivity(new Intent(baseActivity, TripInformationActivity.class));
			break;

		default:
			break;
		}
		super.onClick(v);
	}
}
